//: C05:MinTest.cpp
#include <cstring>
#include <iostream>
using std::cout;
using std::endl;
using std::strcmp;

template <typename T> const T &min(const T &a, const T &b) {
  return (a < b) ? a : b;
}

const char *min(const char *a, const char *b) {
  return (strcmp(a, b) < 0) ? a : b;
}

double min(double x, double y) { return (x < y) ? x : y; }

int main(void) {
  const char *s2 = "say \"Ni-!\"", *s1 = "knights who";
  cout << min(1, 2) << endl;     // 1: 1 (template)
  cout << min(1.0, 2.0) << endl; // 2: 1 (double)
  cout << min(1, 2.0) << endl;   // 3: 1 (double)
  cout << min(s1, s2) << endl;   // 4: knights who (const char*)

  cout << min<>(s1, s2) << endl; // 5: say "Ni-!" (template)
}